package com.leetcode.algorithm.y22.m09.w4;

/**
 * 2390. 从字符串中移除星号
 * 
 * https://leetcode.cn/problems/removing-stars-from-a-string/
 * 
 * @author jie.deng
 *
 */
class Question2390Solution01 {
	
	public String removeStars(String s) {
		char[] chs = s.toCharArray();
		int nextRestIdx = 0;
		int idx = 0;
		int len = chs.length;
		while (idx < len) {
			if (chs[idx] == '*') {
				nextRestIdx--;
			} else {
				chs[nextRestIdx++] = chs[idx];
			}
			idx++;
		}
		return new String(chs, 0, nextRestIdx);
	}
    
}